# -*- coding: utf-8 -*-
# @Author   : xiongjianwen
# @Time     : 2023/1/5 11:11
# @File     : new_platform_gcxx.py
# @Project  : BwProCost_Auto_v1

# -*- encoding=utf8 -*-
__author__ = "Administrator"

from airtest.core.api import *
import uiautomation as auto
import logging

from commons.basePage import BaseControl
from utils.handle_hanshu import HANSHU
from utils.handle_images import snapshot_images

logger = logging.getLogger("airtest")
logger.setLevel(logging.ERROR) # 减少控制台的日志输出，只打印ERROR的日志。
auto_setup(__file__, devices=["Windows:///"]) # 没有log地址，即使打印ERROR日志也不保存起来

# 进入工程信息界面
def goto_Gcxx(project_path='E:\变电站工程.zwzj'):
    # airtest录制代码
    touch(Template(r"../data/images/tpl1666834747100.png", record_pos=(-0.015, -0.081), resolution=(3520, 1080)))
    keyevent(project_path)
    touch(Template(r"../data/images/tpl1666834866324.png", record_pos=(0.179, -0.01), resolution=(3520, 1080)))
    # 判断打开工程是否正确---进入工程信息
    assert_exists(Template(r"../data/images/tpl1666835353580.png", record_pos=(-0.024, -0.112), resolution=(3520, 1080)),"进入工程信息页面")

class NewPlat_Gcxx(BaseControl):
    # 初始化工程信息窗口，及窗口大小
    def __init__(self,windows_name='变电站工程.zwzj - 博微电力建设计价通软件', **searchProperties):
        super().__init__(**searchProperties)
        self.auto_window = auto.WindowControl(searchDepth=1, Name=windows_name)
        self.hs = HANSHU(model_name='工程信息')
        self.left,self.top,self.right,self.bottom = self.auto_window.BoundingRectangle.left,self.auto_window.BoundingRectangle.top,self.auto_window.BoundingRectangle.right,self.auto_window.BoundingRectangle.bottom
        self.auto_window_rect = (self.left,self.top,self.right,self.bottom)

    # 调用公用函数方法，设置编辑框内容
    def setValueOfJBCS(self,text,value):
        self.hs.setValueOfText_byData(text,value)

    # 调用公共函数方法，选择下拉框的值
    def setItemOfJBCS(self,text,value):
        self.hs.setItemOfText_byData(text,value)

if __name__ == '__main__':
    # goto_Gcxx()
    np = NewPlat_Gcxx()
    # np.setValueOfJBCS('工程名称','修改工程名称')
    # np.setItemOfJBCS('预算类型','可行性研究投资估算')
    # print(np.auto_window.BoundingRectangle)
    # print(np.left,np.top,np.right,np.bottom)
    # print(type(np.auto_window_rect))
    # snapshot_images(np.auto_window_rect, '../data/images_compare/a2.jpg')

    # np.change_gcxx_yslx('可行性研究投资估算')
    # auto_window = auto.WindowControl(searchDepth=1, Name='变电站工程.zwzj - 博微电力建设计价通软件')
    # auto_window.CaptureToImage('../data/images_compare/05.jpg')





